package com.chushouya.order.dto.api.dangdang;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 铛铛API响应DTO
 */
@Data
@ApiModel("铛铛API响应")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DangDangResponse<T> {

    @ApiModelProperty("处理状态码，0正常，非0异常")
    private Integer code;

    @ApiModelProperty("请求处理描述，code为0时可能为空，code不为0返回异常描述")
    private String msg;

    @ApiModelProperty("数据，code为0时data不为空，code不为0时可能为空")
    private T data;

    /**
     * 判断请求是否成功
     * @return 成功返回true，失败返回false
     */
    public boolean isSuccess() {
        return code != null && code == 0;
    }
}
